<template>
  <div class="balance">
    <user-menu active="2" />
    <div class="u-container">
      <ul class="clearfix toptab">
        <li class="tabactive">
          <p>成为Vip</p>
        </li>
      </ul>
      <div class="vipContent">
        <div class="vipTxt">
          成为VIP的权益介绍
        </div>

        <div class="vip-buy">
          <div
            class="vip-list"
            :class="{'active':cardChoice ==index}"
            v-for="(item,index) in cardData"
            :key="index"
            @click="cardChoiceClick(index,item)"
          >
            <h3>{{item.name}}</h3>
            <p class="price">￥{{item.price}}</p>
            <span v-if="item.average">平均每月￥{{item.average}}</span>
            <i class="cardIcon el-icon-postcard"></i>
        </div>
      </div>

      <div class="buyBtnWrap">
        <el-button type="primary">{{buttonTxt}}</el-button>
      </div>

    </div>
  </div>
  </div>
</template>

<script>
import UserMenu from '@/components/UserMenu.vue'
export default {
  components: {
    UserMenu
  },
  data() {
    return {
      cardChoice: 0,
      cardData: [
        {
          name: '年卡会员',
          price: 178,
          average: 14.8
        },
        {
          name: '季卡会员',
          price: 50,
          average: 16.7
        },
        {
          name: '月卡会员',
          price: 19
        }
      ],
      buttonTxt: '购买年卡会员￥178'
    }
  },
  mounted() {},
  methods: {
    cardChoiceClick(index, item) {
      this.cardChoice = index
      this.buttonTxt = `购买${item.name}￥${item.price}`
    }
  }
}
</script>
<style lang="scss">
.vipContent {
  padding: 30px;
  .vipTxt {
    font-size: 14px;
    color: #666;
    padding: 0 0 30px 0;
  }
  .vip-buy {
    display: flex;
    justify-content: space-between;
    .vip-list {
      width: 240px;
      height: 130px;
      box-sizing: border-box;
      border-radius: 4px;
      border: 1px solid #e5e5e5;
      padding: 20px 30px;
      position: relative;
      cursor: pointer;
      h3 {
        font-size: 16px;
        font-weight: 700px;
      }
      .price {
        font-size: 20px;
        margin: 10px 0;
        color: rgba(240, 20, 20, 0.8);
      }
      span {
        font-size: 12px;
        color: #999;
      }
      .cardIcon {
        position: absolute;
        right: 10px;
        top: 10px;
        font-size: 50px;
        color: #ddd;
        opacity: 0.5;
      }
      &.active {
        border-color: #ebd095;
        background-color: #faf5e9;
        .cardIcon {
          color: #dcb371;
        }
      }
    }
  }
  .buyBtnWrap {
    padding: 30px 0;
  }
}
</style>
